﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web;

namespace CoolCode.Web
{
    public static  class Config
    {
        public static string DefaultLanguage
        {
            get
            {
                return ConfigurationSettings.AppSettings["DefaultLanguage"] ??"S";
            }
        }

        public static bool IsDebug
        {
            get
            {
                return (HttpContext.Current != null && HttpContext.Current.IsDebuggingEnabled);
            }
        }


        public static string AppData
        {
            get
            {
               return  Utility.GetMapPath("~/App_Data/");
            } 
        }

        public  static readonly DateTime MinDate = new DateTime(1900, 1, 1);
        public  static readonly DateTime MaxDate = new DateTime(2100, 1, 1);

        public static DateTime Markup(this DateTime date)
        {
            if (date < MinDate || date > MaxDate)
                return MinDate;
            return date;
        }

        public static string CompanyName
        {
            get
            {
                return "广州市康心高分子科技有限公司";
            }
        }

        public static string DateFormat
        {
            get
            {
                return "yyyy-MM-dd";
            }
        }

        public static bool Vailidate(this DateTime? value)
        {
            return  value.GetValueOrDefault().InRange(MinDate, MaxDate);
        }
    }
}
